import org.korifey.ffalg.NumberTheory;


public class Problem3 {
	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static long solve() {
		long n = 600851475143l;		
		int[] primes = NumberTheory.erathosphen(100000000);
		
		long maxfactor = 1;
		long limit = (long)Math.sqrt(n);
		for (int i=0; primes[i]<=limit; i++) {
			while (n % primes[i] == 0) {
				maxfactor = primes[i];
				n /= primes[i];
			}
		}
		
		if (n > maxfactor) {
			return n;
		} else {
			return maxfactor;
		}
	}
}
